package rssApp.models 
{
	import common.events.PropertyEvent;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.utils.Dictionary;
	import rss.IRssEntryModel;
	import rss.IRssFeedModel;
	import rssApp.IRssAppModel;
	
	 /// @eventType = common.events.PropertyEvent.CHANGE
	[Event(name = "PropertyEvent.CHANGE", type = "common.events.PropertyEvent")]
	
	/**
	 * TODO: document
	 * 
	 * @author Luke Van In
	 */
	public class RssAppModel extends EventDispatcher implements IRssAppModel
	{
		
		// constants
		public static const URL:String = "url";
		
		public static const CATEGORIES:String = "categories";
		
		public static const FEED:String = "feed";
		
		
		
		// private variables
		private var _url:String;
		
		private var _categories:Dictionary;
		
		private var _feed:IRssFeedModel;
		
		
		
		
		/**
		 * Constructor
		 * 
		 * @param	url
		 * @param	categories
		 * @param	feed
		 */
		public function RssAppModel(url:String = "", categories:Dictionary = null, feed:IRssFeedModel = null) 
		{
			this._url = url;
			
			this._categories = categories;
			
			this._feed = feed;
		}
		
		
		
		
		
		/* INTERFACE rssApp.IRssAppModel */
		
		/**
		 * 
		 */
		public function get url():String 
		{
			return this._url;
		}
		
		public function set url(url:String):void 
		{
			if (url == this._url)
				return;
				
			this._url = url;
			
			this.dispatchEvent(new PropertyEvent(PropertyEvent.CHANGE, RssAppModel.URL));
		}
		
		
		
		
		/**
		 * 
		 */
		public function get categories():Dictionary 
		{
			return this._categories;
		}
		
		public function set categories(categories:Dictionary):void 
		{
			this._categories = categories;
			
			this.dispatchEvent(new PropertyEvent(PropertyEvent.CHANGE, RssAppModel.CATEGORIES));
		}
				
		
		
		
		/**
		 * 
		 */
		public function get feed():IRssFeedModel 
		{
			return this._feed;
		}
		
		public function set feed(feed:IRssFeedModel):void 
		{
			this._feed = feed;
			
			this.dispatchEvent(new PropertyEvent(PropertyEvent.CHANGE, "feed"));
		}
		
		
		
		
		
		
		/**
		 * 
		 */
		public function dispose():void
		{
			
		}
		
		
	}

}